Challenge #5

Your Objective: Your final challenge is the toughest. Sort the scroll list of names in alphabetical order.*27**991*

Tips and Hints

q There are many ways to sort a list. In Prograph, most sorting algorithms*993* use list, loop, and partition *199*control annotations on roots and terminals. *138*Case structure also comes into play on certain sorts.

 If you are an experienced programmer and want a real challenge, write your sort method from scratch. Otherwise, use Selective Load *972*to bring the sort names universal method in from the Grand Tour Solutions file, located in the in the Ch 3 ƒ folder within the Tutorial Examples ƒ folder. This method performs a*115**992* bubble sort using a mixed list and loop multiplex Local operation. The local uses a comparison test to determine which of its two cases to perform.

 Determine the input and output requirements of sort names and work it into the Update the Name List local method in the Add method.

q Sorting the name list before setting the value list attribute of the *155*scroll list makes the value list order differ from the order of Person objects in People. So don’t forget to modify the Name List click method. You need to use the integer input to phoneNumber to extract the name string from value list. Then search the People list for a Person object with a name attribute that matches the name selected in the scroll list. (A current limitation of this implementation is that it assumes unique names.)

q The*370* find-instance *839*primitive is useful in locating a Person instance in the People persistent list given the individual’s name.

Solution to Challenge #5

 

Solution Comments: This challenge has two distinct parts. The first is to sort the name list. If you wrote your own sort method, congratulations. If you selectively loaded the sort names universal method as suggested, you can learn much about multiplex behavior by running Folks Database with Trace mode on. Inspect the list inputs and outputs as sort names executes. If your list of names is long, you may want to abort *8*execution and turn Trace back off—you may be amazed at how many operations execute to sort a list.

The second task is to adjust your phoneNumber method and phone dialog local method such that you retrieve the correct Person object, since the scroll list and People list are no longer in the same order. To make this work, you have to use all three inputs to the phoneNumber click method. Get the value list from the incoming Scroll List object and use the incoming integer to extract the name string selected in the Name List pane. This name string is then passed into phone dialog. The phone dialog method must be modified to use the*371* *840*find-instance primitive to look for a Person object with a name attribute equal to the string input from phoneNumber.

t The Journey’s End

You have now completed the Grand Tour.

By working your way through the Grand Tour chapters, you have been introduced to a wide range of the features of Prograph. You have experienced the basics of the Prograph language and some of the powerful features that distinguish object-oriented and dataflow programming from traditional software development. You have developed an application with Prograph’s Application Builder, used its powerful editors and challenged your understanding with application enhancements. To enrich your understanding of Prograph, continue on to chapter 4, “Conceptual Foundations,” and Part 2, “Tutorials.”